package com.ficus.road.maintain.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ficus.road.maintain.core.model.*;
import com.ficus.road.maintain.core.model.dataflush.RoadTest;
import com.ficus.road.maintain.core.model.smart.District;
import com.ficus.road.maintain.core.model.smartnew.SmartRoadGps;
import com.ficus.road.maintain.core.model.smartnew.SmartRoadSection;
import com.ficus.road.maintain.core.model.zh.UnitScore;
import com.ficus.road.maintain.dao.*;
import com.ficus.road.maintain.dao.dataflush.RoadTestDao;
import com.ficus.road.maintain.dao.smart.DistrictDao;
import com.ficus.road.maintain.dao.smartnew.SmartProjectDao;
import com.ficus.road.maintain.dao.smartnew.SmartRoadGpsTestDao;
import com.ficus.road.maintain.dao.smartnew.SmartRoadSectionDao;
import com.ficus.road.maintain.service.HitService;
import com.ficus.road.maintain.service.smartnew.SmartRoadGpsService;
import com.ficus.road.maintain.service.smartnew.SmartRoadSectionService;
import com.ficus.road.maintain.task.SmartDecisionTask;
import com.ficus.road.maintain.third.zh.ZHDiseaseLocation;
import com.ficus.road.maintain.util.LngLonUtil;
import com.ficus.road.maintain.util.MyDateUtil;
import com.ficus.road.maintain.util.dingtalk.DingTalkUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 工具controller
 * 直接面向开发人员快速调用接口
 */
@RestController
@RequiredArgsConstructor
@Slf4j
public class UtilController {

    private final HitDao hitDao;
    private final CarDao carDao;
    private final RoadSectionDao roadSectionDao;
    private final RoadTestDao roadTestDao;
    private final DistrictDao districtDao;
    private final RoadInfoDao roadInfoDao;
    private final DingTalkUtil dingTalkUtil;
    private final HitService hitService;
    private final SmartRoadSectionDao smartRoadSectionDao;
    private final SmartDecisionTask smartDecisionTask;
    private final SmartProjectDao smartProjectDao;
    private final SmartRoadGpsTestDao smartRoadGpsTestDao;
    private final SmartRoadGpsService smartRoadGpsService;
    private final SmartRoadSectionService smartRoadSectionService;
    private final GpsHistoryDao gpsHistoryDao;
    private final ZHDiseaseLocation zhDiseaseLocation;
    private final RoadInfoAdditionalDao roadInfoAdditionalDao;
    private final UnitTransferDao unitTransferDao;
    private final UnitDao unitDao;
    private final CompanyDao companyDao;
    private final UnitScoreDao unitScoreDao;

    private static long getTime(LocalDateTime localDateTime) {
        return localDateTime.toEpochSecond(ZoneOffset.of("+8"));
    }

    /**
     * @param carId
     * @return
     */
    @RequestMapping(value = "/confirmAllHits/{carId}",
            method = RequestMethod.GET)
    public ResponseEntity<String> queryTotal(@PathVariable(value = "carId") String carId) {
        Criteria criteria = Criteria.where("attrs.car_id").is(carId).and("attrs.confirmation.status").is("CORRECT");
        Query query = new Query(criteria);
        List<Hit> hitList = hitDao.findByQuery(query);
        for (Hit hit : hitList) {
            HitStatusEnum status = hit.getAttrs().getStatus();
            if (status.equals(HitStatusEnum.NEW) || status.equals(HitStatusEnum.DISPATCHED)
                    || status.equals(HitStatusEnum.SEND) || status.equals(HitStatusEnum.UNDISPATCH) || status.equals(HitStatusEnum.PROCESSING)) {
                hit.getAttrs().setStatus(HitStatusEnum.CONFIRMED);
                hitDao.saveOrUpdate(hit);
            }
        }

        return new ResponseEntity<>("success", HttpStatus.OK);
    }

    @RequestMapping(value = "/test",
            method = RequestMethod.GET)
    public ResponseEntity<String> test() {
//        Date last3MonthAgo = MyDateUtil.getFirstDayOfLastNMonth(3);
//        Criteria criteria = Criteria.where("first_hit_time").gte(last3MonthAgo.getTime() / 1000).and("attrs.confirmation.status").is("CORRECT");
//        criteria.and("type").is("PIC_WORKING_DISEASE_RESULT_DISEASE_ROAD_DOCUMENTED");
//        List<Hit> byQuery = hitDao.findHitBySmart(new Query(criteria));
//
//        int i = 0;
//        int j = 0;
//        for (Hit hit : byQuery) {
//            Long firstHitTime = hit.getFirstHitTime();
//            Date date = new Date(firstHitTime * 1000);
//            int hours = date.getHours();
//            if ((hours > 7 && hours < 9) || (hours > 16 && hours < 18)) {
//                i++;
//            } else {
//                j++;
//            }
//            String roadType = hit.getAttrs().getRoadType();
//            if (roadType.equals("ROAD_TYPE_ASPHALT")) {
//                i++;
//            } else if (roadType.equals("ROAD_TYPE_CEMENT")) {
//                j++;
//            }
//        }


        List<RoadSection> all1 = roadSectionDao.findAll();
        for (RoadSection roadSection : all1) {
            String gaodeLocation = roadSection.getGaodeLocation();
            if (StringUtils.isNotBlank(gaodeLocation)) {
                List<Coordinate> coordinateList = JSONArray.parseArray(gaodeLocation, Coordinate.class);
                List<Coordinate> wgspoints = coordinateList.stream().map(item -> {
                    String x = item.getX();
                    String y = item.getY();
                    double[] doubles = LngLonUtil.gcj02towgs84(Double.valueOf(x), Double.valueOf(y));
                    Coordinate coordinate = new Coordinate(String.valueOf(doubles[0]), String.valueOf(doubles[1]));
                    return coordinate;
                }).collect(Collectors.toList());
//                roadinfo.setlocai(wgs)
                String s = JSON.toJSONString(wgspoints);
                roadSection.setWgs84Location(s);
                roadSectionDao.saveOrUpdate(roadSection);
            }
        }


//        List<Car> all = carDao.findAll();
//        for (Car car : all) {
//            car.setType("XCC");
//            carDao.saveOrUpdate(car);
//        }
//        List<Road> all = roadDao.findAll();
//        Set<String> pointsSet = new HashSet<>();
//        int i = 0;
//        for (Road road : all) {
//            if (CollectionUtils.isNotEmpty(road.getPoints())) {
//                pointsSet.addAll(road.getPoints());
//                i += road.getPoints().size();
//            }
//        }
//        System.out.println("pointsSet: " + pointsSet.size() + "  i:" + i);
//        for (Road road : all) {
//            if (CollectionUtils.isNotEmpty(road.getPoints())) {
//                List<String> points = road.getPoints();
//                for (int i = 0; i < points.size(); i++) {
//                    List<String> neighbors = new ArrayList<>();
//                    if (i > 0) {
//                        neighbors.add(points.get(i - 1));
//                    }
//                    if (i < points.size() - 1) {
//                        neighbors.add(points.get(i + 1));
//                    }
//                    UnitKeyPoint fetch = unitKeyPointDao.fetch(points.get(i) + "_" + road.getId());
//                    fetch.setNeighbors(new HashSet<>(neighbors));
//                    unitKeyPointDao.saveOrUpdate(fetch);
//                }
//            }
//        }
//        List<RoadTest> all = roadTestDao.findAll();
//        for (RoadTest roadTest : all) {
//            if (StringUtils.isNotBlank(roadTest.getPoints())) {
//                Road road = roadDao.fetch(roadTest.getId());
//                List<List> lists = JSON.parseArray(roadTest.getPoints(), List.class);
//                List<String> points = new ArrayList<>();
//                List<GpsLocation> pointsLocations = new ArrayList<>();
//                for (int i = 0; i < lists.size(); i++) {
//                    List list = lists.get(i);
//                    Double longitude = Double.valueOf(list.get(0).toString());
//                    Double latitude = Double.valueOf(list.get(1).toString());
//                    GpsLocation gpsLocation = GpsLocation.builder().longitude(longitude).latitude(latitude).build();
//                    String s = gpsToString(gpsLocation);
//                    if (!points.contains(s)) {
//                        points.add(s);
//                        pointsLocations.add(gpsLocation);
//                    }
////                    UnitKeyPoint unitKeyPoint = new UnitKeyPoint();
////                    unitKeyPoint.setKeyPoint(s);
////                    unitKeyPoint.setUnitId(roadTest.getUnitId());
////                    unitKeyPoint.setRoadId(roadTest.getId());
////                    unitKeyPoint.setGpsLocation(gpsLocation);
////                    unitKeyPoint.setRoadName(roadTest.getRoadName());
////                    unitKeyPoint.setId(s + "_" + roadTest.getId());
////                    unitKeyPointDao.saveOrUpdate(unitKeyPoint);
//                }
//                road.setPoints(points);
//                road.setPointsLocation(pointsLocations);
//                roadDao.saveOrUpdate(road);
//            }
//        }

        return new ResponseEntity<>("success", HttpStatus.OK);
    }

    public String gpsToString(GpsLocation gpsLocation) {
        return ((Double) (gpsLocation.getLongitude() * 1000)).intValue() + "_" + ((Double) (gpsLocation.getLatitude() * 1000)).intValue();
    }

    /**
     * 03-03日刷数据
     *
     * @return
     */
    @GetMapping("/dataFlush/0000")
    public ResponseEntity<String> dataFlush() {
        List<RoadTest> testList = roadTestDao.findAll();
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
        testList.forEach(roadTest -> {
            if (roadTest.getRoadName().equals("机场大道") || roadTest.getRoadName().equals("华东北路、港绣路")) {
                Query query = new Query(Criteria.where("name").is(roadTest.getDistrictName()));
                District district = districtDao.findOne(query);
                RoadInfo roadInfo = new RoadInfo();
                roadInfo.setId(roadTest.getSecNum() + (ObjectUtils.isEmpty(district) ? "#" : district.getId()));
                roadInfo.setSecNum(roadTest.getSecNum());
                roadInfo.setRoadType(RoadTypeEnum.DIRECT);
                roadInfo.setDistrictId(ObjectUtils.isEmpty(district) ? " " : district.getId());
                roadInfo.setTown(roadTest.getDistrictName());
                roadInfo.setUnitId(roadTest.getUnitId());
                roadInfo.setRoadName(roadTest.getRoadName());
                roadInfo.setStartStake(roadTest.getStartStake());
                roadInfo.setEndStake(roadTest.getEndStake());
                roadInfo.setCoordinates(convertGpsToCoordinate(mapper, roadTest.getGaodeLocation(), roadTest.getRoadName()));
                roadInfoDao.saveOrUpdate(roadInfo);
            }
        });
        return new ResponseEntity<>("success", HttpStatus.OK);
    }

//    @GetMapping("/test/GEO")
//    public ResponseEntity<String> testGEO() {
//        GpsLocation gpsLocation = GpsLocation.builder().longitude(121.583230107d).latitude(31.22409226d).build();
//        List<Hit> geoSearch = hitService.geoSearch(gpsLocation, "PIC_RED_AND_WHITE_ROD_DISEASE_RESULT_DISEASE_TILT");
//        List<Hit> aggregate2 = hitService.aggregate2(gpsLocation, "PIC_RED_AND_WHITE_ROD_DISEASE_RESULT_DISEASE_TILT");
//        log.info("" + geoSearch.size());
//        log.info("" + aggregate2.size());
//        return new ResponseEntity<>("success", HttpStatus.OK);
//    }

    public List<Coordinate> convertGpsToCoordinate(ObjectMapper mapper, String s, String roadName) {
        List<Coordinate> res = new ArrayList<>();
        // 1.从字符串中截取出坐标信息
        if (roadName.equals("龙东高架")) {
            // [x,y],...,[x,y]
            // 去掉所有中括号
            String newStr = s.replaceAll("[\\[\\]]", "");
            String[] split = newStr.split(",");
            int i = 0;
            while (i < split.length) {
                double x = Double.parseDouble(split[i]);
                double y = Double.parseDouble(split[++i]);
                y = y < 30 ? y + 30 : y;
                double[] doubles = LngLonUtil.gcj02towgs84(x, y);
                Coordinate coordinate = new Coordinate(doubles[0] + "", doubles[1] + "");
                res.add(coordinate);
                i++;
            }
        } else {
            // [{x:121.25,y:31.20},...,{x:121.25,y:31.20}]
            try {
                res = mapper.readValue(s, new TypeReference<List<Coordinate>>() {
                });
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        res.forEach(coordinate -> {
            double[] wgs84 = LngLonUtil.gcj02towgs84(Double.parseDouble(coordinate.getX()), Double.parseDouble(coordinate.getY()));
            coordinate.setX(wgs84[0] + "");
            coordinate.setY(wgs84[1] + "");
        });
        return res;
    }

    /**
     * 刷智慧决策路段数据
     *
     * @return
     */
    @GetMapping("/dataFlush/0301")
    public ResponseEntity<String> dataFlushSmart() {
        // 整理smartRoadSection数据
        organizeRoadSectionData();

//        Date date = new Date();
//        Map<String, String> nameIdMap = smartRoadSectionDao.findAll().stream().collect(Collectors.toMap(SmartRoadSection::getRoadName, SmartRoadSection::getId));
//        Map<String, String> nameTypeMap = smartRoadSectionDao.findAll().stream().collect(Collectors.toMap(SmartRoadSection::getRoadName, SmartRoadSection::getRoadType));
//        for (int i = 0; i >= -11; i--) {
//            Date endDate = DateUtils.addDays(date, i * 30);
//            Date startDate = DateUtils.addDays(endDate, -30);
//            Query query = new Query(Criteria.where("first_hit_time").gte(startDate.getTime() / 1000).lte(endDate.getTime() / 1000));
//            List<Hit> hits = hitDao.findByQuery(query);
//            hits.forEach(hit -> {
//                nameIdMap.keySet().stream().forEach(roadName -> {
//                    if (ObjectUtils.isEmpty(hit.getAttrs().getRoadName())) {
//                        return;
//                    }
//                    // 演示新增
//                    int idx = roadName.indexOf("-");
//                    roadName = roadName.substring(0, idx);
//                    if (hit.getAttrs().getRoadName().contains(roadName)) {
//                        log.info(hit.getAttrs().getRoadName());
//                        log.info(roadName);
//                        hit.getAttrs().setSmartRoadSecId(nameIdMap.get(roadName));
//                        hit.getAttrs().setSmartRoasSecType(nameTypeMap.get(roadName));
//                        hitDao.saveOrUpdate(hit);
//                        return;
//                    }
//                });
//            });
//        }
        return new ResponseEntity<>("success", HttpStatus.OK);
    }

    /**
     * 整理smartRoadSection数据
     */
    public void organizeRoadSectionData() {
        List<SmartRoadSection> roadSectionList = smartRoadSectionService.findAllSection();
//        List<SmartRoadSection> toBeDelete = roadSectionList.stream()
//                .filter(road -> ObjectUtils.isEmpty(road.getPCI()) || ObjectUtils.isEmpty(road.getRQI())
//                        || ObjectUtils.isEmpty(road.getRDI()) || ObjectUtils.isEmpty(road.getPSSI()))
//                .collect(Collectors.toList());
//        toBeDelete.parallelStream().forEach(road -> {
//            smartRoadSectionService.deleteById(road.getId());
//        });
//        roadSectionList = smartRoadSectionService.findAllSection();
        roadSectionList.stream().collect(Collectors.groupingBy(item -> item.getRoadName())).forEach((roadName, roadList) -> {
//            AtomicInteger atomicInteger = new AtomicInteger(1);
            roadList.forEach(road -> {
//                road.setRoadName(road.getRoadName() + "-" + atomicInteger.getAndIncrement());
                road.setRoadName(road.getRoadName() + "-" + road.getStartStake());
                smartRoadSectionDao.saveOrUpdate(road);
            });
        });
    }

    @GetMapping("/dataFlush/0302")
    public ResponseEntity<String> dataFlushSmart2() {
        Date date = new Date();
        smartRoadSectionDao.findAll().forEach(sec -> {
//            sec.setLastModificationTime(MyDateUtil.dateFormatStr(date, "yyyy-MM-dd"));
//            sec.setIsProject(Boolean.FALSE);
//            sec.setIsReserve(Boolean.FALSE);
            smartRoadSectionDao.saveOrUpdate(sec);
        });
        return new ResponseEntity<>("success", HttpStatus.OK);
    }

    @GetMapping("/dataFlush/0304")
    public ResponseEntity<String> dataFlushSmart3() {
        //        highwayScreeningStatistic();
//        // 智能检测
//        highwayInspectionStatistic();
//        // 智能排序
//        highwaySortStatistic();
//        // 智能估价
//        highwayValuationStatistic();

//        List<SmartRoadSection> all = smartProjectDao.findAll();
//        all.stream().collect(Collectors.groupingBy(Smartroadse))

//        smartDecisionTask.highwayScreeningStatistic();
//        smartDecisionTask.highwayInspectionStatistic();
//        smartDecisionTask.highwaySortStatistic();
//        smartDecisionTask.highwayValuationStatistic();

//        smartDecisionTask.refreshSmartRoadOfHit();


        Date endDate = new Date();
        Date startDate = DateUtils.addDays(new Date(), -30);
        for (int i = 0; i <= 12; i++) {
            System.out.println("开始时间: " + MyDateUtil.dateFormatStr(startDate, "yyyy-MM-dd"));
            System.out.println("结束时间: " + MyDateUtil.dateFormatStr(endDate, "yyyy-MM-dd"));
            Query query = new Query();
            query.addCriteria(Criteria.where("first_hit_time").gte(startDate.getTime() / 1000).lte(endDate.getTime() / 1000).and("attrs.smart_road_sec_id").ne(null).and("attrs.smart_roas_sec_type").ne(null));
            List<Hit> hits = hitDao.findByQuery(query);
            hits.forEach(hit -> {
                hit.getAttrs().setSmartRoadSecId(null);
                hit.getAttrs().setSmartRoasSecType(null);
                hitDao.saveOrUpdate(hit);
            });
            startDate = DateUtils.addDays(startDate, -30);
            endDate = DateUtils.addDays(endDate, -30);
        }
        return new ResponseEntity<>("success", HttpStatus.OK);
    }

    @GetMapping("/dataFlush/0303")
    public ResponseEntity<String> dataFlushSmartRoadGps() {
        smartRoadGpsTestDao.findAll().forEach(road -> {
            SmartRoadSection roadSection = smartRoadSectionDao.findOne(new Query(Criteria.where("road_name").is(road.getRoadName())));
            String str = road.getCoStr();
            if (StringUtils.isEmpty(str)) {
                return;
            }
            // [x,y],...,[x,y]
            // 去掉所有中括号
            String newStr = str.replaceAll("[\\[\\]]", "");
            String[] split = newStr.split(",");
            int i = 0;
            while (i < split.length) {
                double x = Double.parseDouble(split[i++]);
                double y = Double.parseDouble(split[i++]);
                List<Double> location = Arrays.asList(x, y);
                SmartRoadGps smartRoadGps = SmartRoadGps.builder().roadName(road.getRoadName()).secName(road.getSecName())
                        .location(location).secId(roadSection.getId()).build();
                smartRoadGpsService.saveOrUpdate(smartRoadGps);
            }
        });
        return new ResponseEntity<>("success", HttpStatus.OK);
    }

    @GetMapping("/jumpPoint/network")
    public ResponseEntity<String> checkJumpPointForNetwork() {
        LocalDateTime start = LocalDateTime.of(2022, 03, 21, 0, 0);
        for (int i = 0; i <= 30; i++) {
            log.info("开始校验: {}", start);
            LocalDateTime end = start.plusDays(1);
            Query query = new Query(Criteria.where("timestamp").gte(getTime(start)).lte(getTime(end)));
            query.with(new Sort(Sort.Direction.ASC, "timestamp"));
            List<GpsHistory> gpsHistories = gpsHistoryDao.findByQuery(query);
            gpsHistories.stream().collect(Collectors.groupingBy(GpsHistory::getCarId)).forEach((carId, list) -> {
                for (int j = 0; j < list.size() - 1; j++) {
                    GpsHistory pre = list.get(j);
                    GpsHistory post = list.get(j + 1);
                    long l = post.getTimestamp() - pre.getTimestamp();
                    if (l > 2) {
                        log.info("间隔: {}, carId: {}, pre: {}, post: {}", l, carId, pre.getTimestamp(), post.getTimestamp());
                    }
                }
            });
            start = end;
        }
        return new ResponseEntity<>("finish", HttpStatus.OK);
    }

    @GetMapping("/diseaseLocation/sync")
    public ResponseEntity<String> syncDiseaseLocation() {
        try {
            zhDiseaseLocation.refreshDiseaseLocation();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ResponseEntity<>("string", HttpStatus.OK);
    }

    @GetMapping("/roadInfo")
    public void refreshRoadInfo() {
        List<RoadInfoAdditional> all = roadInfoAdditionalDao.findAll();
        all.stream().forEach(roadInfoAdditional -> {
            String json = roadInfoAdditional.getCoordinates();
            List<Coordinate> coordinates = JSONArray.parseArray(json, Coordinate.class);
            roadInfoAdditional.setId(roadInfoAdditional.getUnitId() + "-" + roadInfoAdditional.getSecNum());
            roadInfoAdditional.setCoordinateList(coordinates);
            roadInfoAdditionalDao.saveOrUpdate(roadInfoAdditional);
        });
        System.out.println("finish");
    }

    @PostMapping("/refresh/unit")
    public void refreshUnit() {
        unitTransferDao.findAll().forEach(unitTransfer -> {
            List<Unit> unitList = unitDao.findByQuery(new Query(Criteria.where("_id").is(unitTransfer.getUnitIdOld())));
            if (unitList.size() != 1) {
                log.error("error, unitSize: {}, unitId: {}", unitList.size(), unitTransfer.getUnitIdOld());
                return;
            }
            Unit unit = unitList.get(0);
            unitDao.deleteById(unit.getId());
            Unit newUnit = Unit.builder().id(unitTransfer.getId()).unitName(unitTransfer.getUnitName()).roadType(RoadTypeEnum.HIGHWAY.toString()).build();
            unitDao.saveOrUpdate(newUnit);
        });
    }

    @PostMapping("/refresh/company")
    public void refreshCompany() {
        Set<String> unitIdSet = unitDao.findAll().stream().map(Unit::getId).collect(Collectors.toSet());
        Map<String, List<String>> companyIdUnitMap = unitDao.findByQuery(new Query(Criteria.where("road_type").is(RoadTypeEnum.HIGHWAY)))
                .stream()
                .map(Unit::getId)
                .collect(Collectors.groupingBy(item -> item.split("-")[0]));
        List<Company> companies = companyDao.findAll();
        companies.forEach(company -> {
            List<String> highwayUnitId = companyIdUnitMap.get(company.getId());
            Set<String> units = company.getUnits();
            if (CollectionUtils.isNotEmpty(units)) {
                units.retainAll(unitIdSet);
            }
            if (CollectionUtils.isNotEmpty(highwayUnitId)) {
                units.addAll(highwayUnitId);
            }
            System.out.println(units);
            companyDao.saveOrUpdate(company);
        });
    }

    //    @Scheduled(cron = "0/5 * * * * ?")
    void refreshRoadUnitScore() {
        List<Unit> roadUnit = unitDao.findByQuery(new Query(Criteria.where("road_type").is(RoadTypeEnum.HIGHWAY.toString())));
        roadUnit.stream().map(unit -> UnitScore.builder()
                .id(unit.getId())
                .unitId(unit.getId())
                .unitName(unit.getUnitName())
                .total(0)
                .date("2022-07")
                .type("ROAD")
                .build()
        ).forEach(unitScoreDao::saveOrUpdate);
    }
}
